<!doctype html>



  


<html class="theme-next muse use-motion" lang="zh-Hans">
<head>
  <meta charset="UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1"/>









<meta http-equiv="Cache-Control" content="no-transform" />
<meta http-equiv="Cache-Control" content="no-siteapp" />















  
  
  <link href="/lib/fancybox/source/jquery.fancybox.css?v=2.1.5" rel="stylesheet" type="text/css" />




  
  
  
  

  
    
    
  

  

  

  

  

  
    
    
    <link href="//fonts.googleapis.com/css?family=Lato:300,300italic,400,400italic,700,700italic&subset=latin,latin-ext" rel="stylesheet" type="text/css">
  






<link href="/lib/font-awesome/css/font-awesome.min.css?v=4.6.2" rel="stylesheet" type="text/css" />

<link href="/css/main.css?v=5.1.1" rel="stylesheet" type="text/css" />


  <meta name="keywords" content="Linux命令," />








  <link rel="shortcut icon" type="image/x-icon" href="/favicon.ico?v=5.1.1" />






<meta name="description" content="&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;Linux系统的ping命令是常用的网络命令，它通常用来测试与目标主机的连通性，我们经常会说“ping一下某机器，看是不是开着”、不能打开网页时会说“你先ping网关地址192.168.1.1试试”。它通过发送ICMP ECHO_REQUEST数据包到网络主机（send ICMP ECHO_REQUES">
<meta name="keywords" content="Linux命令">
<meta property="og:type" content="article">
<meta property="og:title" content="Linux 命令- ping">
<meta property="og:url" content="https://hcldirgit.github.io/2017/09/03/2. Linux 命令/56. Linux 命令- ping/index.html">
<meta property="og:site_name" content="失落的乐章">
<meta property="og:description" content="&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;Linux系统的ping命令是常用的网络命令，它通常用来测试与目标主机的连通性，我们经常会说“ping一下某机器，看是不是开着”、不能打开网页时会说“你先ping网关地址192.168.1.1试试”。它通过发送ICMP ECHO_REQUEST数据包到网络主机（send ICMP ECHO_REQUES">
<meta property="og:locale" content="zh-Hans">
<meta property="og:updated_time" content="2017-09-01T08:37:07.594Z">
<meta name="twitter:card" content="summary">
<meta name="twitter:title" content="Linux 命令- ping">
<meta name="twitter:description" content="&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;Linux系统的ping命令是常用的网络命令，它通常用来测试与目标主机的连通性，我们经常会说“ping一下某机器，看是不是开着”、不能打开网页时会说“你先ping网关地址192.168.1.1试试”。它通过发送ICMP ECHO_REQUEST数据包到网络主机（send ICMP ECHO_REQUES">



<script type="text/javascript" id="hexo.configurations">
  var NexT = window.NexT || {};
  var CONFIG = {
    root: '/',
    scheme: 'Muse',
    sidebar: {"position":"left","display":"post","offset":12,"offset_float":0,"b2t":false,"scrollpercent":false},
    fancybox: true,
    motion: true,
    duoshuo: {
      userId: '0',
      author: '博主'
    },
    algolia: {
      applicationID: '',
      apiKey: '',
      indexName: '',
      hits: {"per_page":10},
      labels: {"input_placeholder":"Search for Posts","hits_empty":"We didn't find any results for the search: ${query}","hits_stats":"${hits} results found in ${time} ms"}
    }
  };
</script>



  <link rel="canonical" href="https://hcldirgit.github.io/2017/09/03/2. Linux 命令/56. Linux 命令- ping/"/>





  <title>Linux 命令- ping | 失落的乐章</title>
</head>

<body itemscope itemtype="http://schema.org/WebPage" lang="zh-Hans">

  




<script>
  (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
            (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
          m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
  })(window,document,'script','https://www.google-analytics.com/analytics.js','ga');
  ga('create', '85*****1', 'auto');
  ga('send', 'pageview');
</script>


  <script type="text/javascript">
    var _hmt = _hmt || [];
    (function() {
      var hm = document.createElement("script");
      hm.src = "https://hm.baidu.com/hm.js?87980c**************99ec5e26fb5";
      var s = document.getElementsByTagName("script")[0];
      s.parentNode.insertBefore(hm, s);
    })();
  </script>











  
  
    
  

  <div class="container sidebar-position-left page-post-detail ">
    <div class="headband"></div>

    <header id="header" class="header" itemscope itemtype="http://schema.org/WPHeader">
      <div class="header-inner"><div class="site-brand-wrapper">
  <div class="site-meta ">
    

    <div class="custom-logo-site-title">
      <a href="/"  class="brand" rel="start">
        <span class="logo-line-before"><i></i></span>
        <span class="site-title">失落的乐章</span>
        <span class="logo-line-after"><i></i></span>
      </a>
    </div>
      
        <p class="site-subtitle">技术面前，永远都是学生。</p>
      
  </div>

  <div class="site-nav-toggle">
    <button>
      <span class="btn-bar"></span>
      <span class="btn-bar"></span>
      <span class="btn-bar"></span>
    </button>
  </div>
</div>

<nav class="site-nav">
  

  
    <ul id="menu" class="menu">
      
        
        <li class="menu-item menu-item-home">
          <a href="/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-home"></i> <br />
            
            首页
          </a>
        </li>
      
        
        <li class="menu-item menu-item-categories">
          <a href="/categories" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-th"></i> <br />
            
            分类
          </a>
        </li>
      
        
        <li class="menu-item menu-item-tags">
          <a href="/tags" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-tags"></i> <br />
            
            标签
          </a>
        </li>
      
        
        <li class="menu-item menu-item-message">
          <a href="/message" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-external-link"></i> <br />
            
            留言
          </a>
        </li>
      

      
    </ul>
  

  
</nav>



 </div>
    </header>

    <main id="main" class="main">
      <div class="main-inner">
        <div class="content-wrap">
          <div id="content" class="content">
            

  <div id="posts" class="posts-expand">
    

  

  
  
  

  <article class="post post-type-normal " itemscope itemtype="http://schema.org/Article">
    <link itemprop="mainEntityOfPage" href="https://hcldirgit.github.io/2017/09/03/2. Linux 命令/56. Linux 命令- ping/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="name" content="失落的乐章">
      <meta itemprop="description" content="">
      <meta itemprop="image" content="/images/0.png">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="失落的乐章">
    </span>

    
      <header class="post-header">

        
        
          <h1 class="post-title" itemprop="name headline">Linux 命令- ping</h1>
        

        <div class="post-meta">
          <span class="post-time">
            
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              
                <span class="post-meta-item-text">发表于</span>
              
              <time title="创建于" itemprop="dateCreated datePublished" datetime="2017-09-03T01:57:34+08:00">
                2017-09-03
              </time>
            

            

            
          </span>

          

          
            
          

          
          

          

          

          

        </div>
      </header>
    

    <div class="post-body" itemprop="articleBody">

      
      

      
        <p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;Linux系统的ping命令是常用的网络命令，它通常用来测试与目标主机的连通性，我们经常会说“ping一下某机器，看是不是开着”、不能打开网页时会说“你先ping网关地址192.168.1.1试试”。它通过发送ICMP ECHO_REQUEST数据包到网络主机（send ICMP ECHO_REQUEST to network hosts），并显示响应情况，这样我们就可以根据它输出的信息来确定目标主机是否可访问（但这不是绝对的）。有些服务器为了防止通过ping探测到，通过防火墙设置了禁止ping或者在内核参数中禁止ping，这样就不能通过ping确定该主机是否还处于开启状态。<br>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;linux下的ping和windows下的ping稍有区别,linux下ping不会自动终止,需要按ctrl+c终止或者用参数-c指定要求完成的回应次数。</p>
<h2 id="1-命令格式"><a href="#1-命令格式" class="headerlink" title="1.命令格式"></a>1.命令格式</h2><figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div></pre></td><td class="code"><pre><div class="line">ping [参数] [主机名或IP地址]</div></pre></td></tr></table></figure>
<h2 id="2-命令功能"><a href="#2-命令功能" class="headerlink" title="2.命令功能"></a>2.命令功能</h2><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;ping命令用于：确定网络和各外部主机的状态；跟踪和隔离硬件和软件问题；测试、评估和管理网络。如果主机正在运行并连在网上，它就对回送信号进行响应。每个回送信号请求包含一个网际协议（IP）和 ICMP 头，后面紧跟一个 tim 结构，以及来填写这个信息包的足够的字节。缺省情况是连续发送回送信号请求直到接收到中断信号（Ctrl-C)。</p>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;ping 命令每秒发送一个数据报并且为每个接收到的响应打印一行输出。ping 命令计算信号往返时间和(信息)包丢失情况的统计信息，并且在完成之后显示一个简要总结。ping 命令在程序超时或当接收到 SIGINT 信号时结束。Host 参数或者是一个有效的主机名或者是因特网地址。</p>
<h2 id="3-命令参数"><a href="#3-命令参数" class="headerlink" title="3.命令参数"></a>3.命令参数</h2><ul>
<li>-d 使用Socket的SO_DEBUG功能。</li>
<li>-f  极限检测。大量且快速地送网络封包给一台机器，看它的回应。</li>
<li>-n 只输出数值。</li>
<li>-q 不显示任何传送封包的信息，只显示最后的结果。</li>
<li>-r 忽略普通的Routing Table，直接将数据包送到远端主机上。通常是查看本机的网络接口是否有问题。</li>
<li>-R 记录路由过程。</li>
<li>-v 详细显示指令的执行过程。</li>
<li><p>-c 数目：在发送指定数目的包后停止。</p></li>
<li>-i 秒数：设定间隔几秒送一个网络封包给一台机器，预设值是一秒送一次。</li>
<li>-I 网络界面：使用指定的网络界面送出数据包。</li>
<li>-l 前置载入：设置在送出要求信息之前，先行发出的数据包。</li>
<li>-p 范本样式：设置填满数据包的范本样式。</li>
<li>-s 字节数：指定发送的数据字节数，预设值是56，加上8字节的ICMP头，一共是64ICMP数据字节。</li>
<li>-t 存活数值：设置存活数值TTL的大小。</li>
</ul>
<h2 id="4-使用实例"><a href="#4-使用实例" class="headerlink" title="4.使用实例"></a>4.使用实例</h2><h3 id="实例1：ping的通的情况"><a href="#实例1：ping的通的情况" class="headerlink" title="实例1：ping的通的情况"></a>实例1：ping的通的情况</h3><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;<strong>命令</strong></p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div></pre></td><td class="code"><pre><div class="line">ping 192.168.120.205</div></pre></td></tr></table></figure>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;<strong>输出</strong></p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div><div class="line">11</div><div class="line">12</div></pre></td><td class="code"><pre><div class="line">[root@localhost ~]<span class="comment"># ping 192.168.120.205</span></div><div class="line">PING 192.168.120.205 (192.168.120.205) 56(84) bytes of data.</div><div class="line">64 bytes from 192.168.120.205: icmp_seq=1 ttl=64 time=0.720 ms</div><div class="line">64 bytes from 192.168.120.205: icmp_seq=2 ttl=64 time=0.181 ms</div><div class="line">64 bytes from 192.168.120.205: icmp_seq=3 ttl=64 time=0.191 ms</div><div class="line">64 bytes from 192.168.120.205: icmp_seq=4 ttl=64 time=0.188 ms</div><div class="line">64 bytes from 192.168.120.205: icmp_seq=5 ttl=64 time=0.189 ms</div><div class="line"></div><div class="line">--- 192.168.120.205 ping statistics ---</div><div class="line">5 packets transmitted, 5 received, 0% packet loss, time 4000ms</div><div class="line">rtt min/avg/max/mdev = 0.181/0.293/0.720/0.214 ms</div><div class="line">[root@localhost ~]<span class="comment">#</span></div></pre></td></tr></table></figure>
<h3 id="实例2：ping不通的情况"><a href="#实例2：ping不通的情况" class="headerlink" title="实例2：ping不通的情况"></a>实例2：ping不通的情况</h3><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;<strong>命令</strong></p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div></pre></td><td class="code"><pre><div class="line">ping 192.168.120.202</div></pre></td></tr></table></figure>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;<strong>输出</strong></p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div><div class="line">11</div><div class="line">12</div><div class="line">13</div></pre></td><td class="code"><pre><div class="line">[root@localhost ~]<span class="comment"># ping 192.168.120.202</span></div><div class="line">PING 192.168.120.202 (192.168.120.202) 56(84) bytes of data.</div><div class="line">From 192.168.120.204 icmp_seq=1 Destination Host Unreachable</div><div class="line">From 192.168.120.204 icmp_seq=2 Destination Host Unreachable</div><div class="line">From 192.168.120.204 icmp_seq=3 Destination Host Unreachable</div><div class="line">From 192.168.120.204 icmp_seq=4 Destination Host Unreachable</div><div class="line">From 192.168.120.204 icmp_seq=5 Destination Host Unreachable</div><div class="line">From 192.168.120.204 icmp_seq=6 Destination Host Unreachable</div><div class="line"></div><div class="line">--- 192.168.120.202 ping statistics ---</div><div class="line">8 packets transmitted, 0 received, +6 errors, 100% packet loss, time 7005ms</div><div class="line">, pipe 4</div><div class="line">[root@localhost ~]<span class="comment">#</span></div></pre></td></tr></table></figure>
<h3 id="实例3：ping网关"><a href="#实例3：ping网关" class="headerlink" title="实例3：ping网关"></a>实例3：ping网关</h3><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;<strong>命令</strong></p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div></pre></td><td class="code"><pre><div class="line">ping -b 192.168.120.1</div></pre></td></tr></table></figure>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;<strong>输出</strong></p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div><div class="line">11</div><div class="line">12</div><div class="line">13</div><div class="line">14</div><div class="line">15</div><div class="line">16</div><div class="line">17</div><div class="line">18</div></pre></td><td class="code"><pre><div class="line">[root@localhost ~]<span class="comment"># route</span></div><div class="line">Kernel IP routing table</div><div class="line">Destination     Gateway         Genmask         Flags Metric Ref    Use Iface</div><div class="line">192.168.120.0   *               255.255.255.0   U     0      0        0 eth0</div><div class="line">192.168.0.0     192.168.120.1   255.255.0.0     UG    0      0        0 eth0</div><div class="line">10.0.0.0        192.168.120.1   255.0.0.0       UG    0      0        0 eth0</div><div class="line">default         192.168.120.240 0.0.0.0         UG    0      0        0 eth0</div><div class="line">[root@localhost ~]<span class="comment"># ping -b 192.168.120.1</span></div><div class="line">PING 192.168.120.1 (192.168.120.1) 56(84) bytes of data.</div><div class="line">64 bytes from 192.168.120.1: icmp_seq=1 ttl=255 time=2.02 ms</div><div class="line">64 bytes from 192.168.120.1: icmp_seq=2 ttl=255 time=1.83 ms</div><div class="line">64 bytes from 192.168.120.1: icmp_seq=3 ttl=255 time=1.68 ms</div><div class="line">64 bytes from 192.168.120.1: icmp_seq=4 ttl=255 time=1.98 ms</div><div class="line">64 bytes from 192.168.120.1: icmp_seq=5 ttl=255 time=1.88 ms</div><div class="line"></div><div class="line">--- 192.168.120.1 ping statistics ---</div><div class="line">5 packets transmitted, 5 received, 0% packet loss, time 4000ms</div><div class="line">rtt min/avg/max/mdev = 1.682/1.880/2.020/0.129 ms</div></pre></td></tr></table></figure>
<h3 id="实例4：ping指定次数"><a href="#实例4：ping指定次数" class="headerlink" title="实例4：ping指定次数"></a>实例4：ping指定次数</h3><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;<strong>命令</strong></p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div></pre></td><td class="code"><pre><div class="line">ping -c 10 192.168.120.206</div></pre></td></tr></table></figure>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;<strong>输出</strong></p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div><div class="line">11</div><div class="line">12</div><div class="line">13</div><div class="line">14</div><div class="line">15</div><div class="line">16</div><div class="line">17</div></pre></td><td class="code"><pre><div class="line">[root@localhost ~]<span class="comment"># ping -c 10 192.168.120.206</span></div><div class="line">PING 192.168.120.206 (192.168.120.206) 56(84) bytes of data.</div><div class="line">64 bytes from 192.168.120.206: icmp_seq=1 ttl=64 time=1.25 ms</div><div class="line">64 bytes from 192.168.120.206: icmp_seq=2 ttl=64 time=0.260 ms</div><div class="line">64 bytes from 192.168.120.206: icmp_seq=3 ttl=64 time=0.242 ms</div><div class="line">64 bytes from 192.168.120.206: icmp_seq=4 ttl=64 time=0.271 ms</div><div class="line">64 bytes from 192.168.120.206: icmp_seq=5 ttl=64 time=0.274 ms</div><div class="line">64 bytes from 192.168.120.206: icmp_seq=6 ttl=64 time=0.295 ms</div><div class="line">64 bytes from 192.168.120.206: icmp_seq=7 ttl=64 time=0.269 ms</div><div class="line">64 bytes from 192.168.120.206: icmp_seq=8 ttl=64 time=0.270 ms</div><div class="line">64 bytes from 192.168.120.206: icmp_seq=9 ttl=64 time=0.253 ms</div><div class="line">64 bytes from 192.168.120.206: icmp_seq=10 ttl=64 time=0.289 ms</div><div class="line"></div><div class="line">--- 192.168.120.206 ping statistics ---</div><div class="line">10 packets transmitted, 10 received, 0% packet loss, time 9000ms</div><div class="line">rtt min/avg/max/mdev = 0.242/0.367/1.251/0.295 ms</div><div class="line">[root@localhost ~]<span class="comment">#</span></div></pre></td></tr></table></figure>
<h3 id="实例5：时间间隔和次数限制的ping"><a href="#实例5：时间间隔和次数限制的ping" class="headerlink" title="实例5：时间间隔和次数限制的ping"></a>实例5：时间间隔和次数限制的ping</h3><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;<strong>命令</strong></p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div></pre></td><td class="code"><pre><div class="line">ping -c 10 -i 0.5 192.168.120.206</div></pre></td></tr></table></figure>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;<strong>输出</strong></p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div><div class="line">11</div><div class="line">12</div><div class="line">13</div><div class="line">14</div><div class="line">15</div><div class="line">16</div><div class="line">17</div><div class="line">18</div><div class="line">19</div><div class="line">20</div><div class="line">21</div><div class="line">22</div><div class="line">23</div><div class="line">24</div><div class="line">25</div><div class="line">26</div><div class="line">27</div><div class="line">28</div><div class="line">29</div><div class="line">30</div><div class="line">31</div><div class="line">32</div><div class="line">33</div></pre></td><td class="code"><pre><div class="line">[root@localhost ~]<span class="comment"># ping -c 10 -i 0.5 192.168.120.206</span></div><div class="line">PING 192.168.120.206 (192.168.120.206) 56(84) bytes of data.</div><div class="line">64 bytes from 192.168.120.206: icmp_seq=1 ttl=64 time=1.24 ms</div><div class="line">64 bytes from 192.168.120.206: icmp_seq=2 ttl=64 time=0.235 ms</div><div class="line">64 bytes from 192.168.120.206: icmp_seq=3 ttl=64 time=0.244 ms</div><div class="line">64 bytes from 192.168.120.206: icmp_seq=4 ttl=64 time=0.300 ms</div><div class="line">64 bytes from 192.168.120.206: icmp_seq=5 ttl=64 time=0.255 ms</div><div class="line">64 bytes from 192.168.120.206: icmp_seq=6 ttl=64 time=0.264 ms</div><div class="line">64 bytes from 192.168.120.206: icmp_seq=7 ttl=64 time=0.263 ms</div><div class="line">64 bytes from 192.168.120.206: icmp_seq=8 ttl=64 time=0.331 ms</div><div class="line">64 bytes from 192.168.120.206: icmp_seq=9 ttl=64 time=0.247 ms</div><div class="line">64 bytes from 192.168.120.206: icmp_seq=10 ttl=64 time=0.244 ms</div><div class="line"></div><div class="line">--- 192.168.120.206 ping statistics ---</div><div class="line">10 packets transmitted, 10 received, 0% packet loss, time 4499ms</div><div class="line">rtt min/avg/max/mdev = 0.235/0.362/1.241/0.294 ms</div><div class="line">[root@localhost ~]<span class="comment"># ping -c 10 -i 0.01 192.168.120.206</span></div><div class="line">PING 192.168.120.206 (192.168.120.206) 56(84) bytes of data.</div><div class="line">64 bytes from 192.168.120.206: icmp_seq=1 ttl=64 time=0.244 ms</div><div class="line">64 bytes from 192.168.120.206: icmp_seq=2 ttl=64 time=0.195 ms</div><div class="line">64 bytes from 192.168.120.206: icmp_seq=3 ttl=64 time=0.219 ms</div><div class="line">64 bytes from 192.168.120.206: icmp_seq=4 ttl=64 time=0.204 ms</div><div class="line">64 bytes from 192.168.120.206: icmp_seq=5 ttl=64 time=3.56 ms</div><div class="line">64 bytes from 192.168.120.206: icmp_seq=6 ttl=64 time=1.93 ms</div><div class="line">64 bytes from 192.168.120.206: icmp_seq=7 ttl=64 time=0.193 ms</div><div class="line">64 bytes from 192.168.120.206: icmp_seq=8 ttl=64 time=0.193 ms</div><div class="line">64 bytes from 192.168.120.206: icmp_seq=9 ttl=64 time=0.202 ms</div><div class="line">64 bytes from 192.168.120.206: icmp_seq=10 ttl=64 time=0.211 ms</div><div class="line"></div><div class="line">--- 192.168.120.206 ping statistics ---</div><div class="line">10 packets transmitted, 10 received, 0% packet loss, time 90ms</div><div class="line">rtt min/avg/max/mdev = 0.193/0.716/3.564/1.080 ms</div><div class="line">[root@localhost ~]<span class="comment">#</span></div></pre></td></tr></table></figure>
<h3 id="实例6：通过域名ping公网上的站点"><a href="#实例6：通过域名ping公网上的站点" class="headerlink" title="实例6：通过域名ping公网上的站点"></a>实例6：通过域名ping公网上的站点</h3><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;<strong>命令</strong></p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div></pre></td><td class="code"><pre><div class="line">ping -c 5 www.58.com</div></pre></td></tr></table></figure>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;<strong>输出</strong></p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div><div class="line">11</div><div class="line">12</div></pre></td><td class="code"><pre><div class="line">peida-VirtualBox ~ <span class="comment"># ping -c 5 www.58.com</span></div><div class="line">PING www.58.com (211.151.111.30) 56(84) bytes of data.</div><div class="line">64 bytes from 211.151.111.30: icmp_req=1 ttl=49 time=14.7 ms</div><div class="line">64 bytes from 211.151.111.30: icmp_req=2 ttl=49 time=16.4 ms</div><div class="line">64 bytes from 211.151.111.30: icmp_req=3 ttl=49 time=15.2 ms</div><div class="line">64 bytes from 211.151.111.30: icmp_req=4 ttl=49 time=14.6 ms</div><div class="line">64 bytes from 211.151.111.30: icmp_req=5 ttl=49 time=19.9 ms</div><div class="line"></div><div class="line">--- www.58.com ping statistics ---</div><div class="line">5 packets transmitted, 5 received, 0% packet loss, time 20101ms</div><div class="line">rtt min/avg/max/mdev = 14.618/16.192/19.917/1.965 ms</div><div class="line">peida-VirtualBox ~ <span class="comment">#</span></div></pre></td></tr></table></figure>
<h3 id="实例7：多参数使用"><a href="#实例7：多参数使用" class="headerlink" title="实例7：多参数使用"></a>实例7：多参数使用</h3><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;<strong>命令</strong></p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div></pre></td><td class="code"><pre><div class="line">ping -i 3 -s 1024 -t 255 192.168.120.206</div></pre></td></tr></table></figure>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;<strong>输出</strong></p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div><div class="line">11</div><div class="line">12</div><div class="line">13</div><div class="line">14</div><div class="line">15</div><div class="line">16</div><div class="line">17</div><div class="line">18</div><div class="line">19</div><div class="line">20</div><div class="line">21</div><div class="line">22</div></pre></td><td class="code"><pre><div class="line">[root@localhost ~]<span class="comment"># ping -i 3 -s 1024 -t 255 192.168.120.206</span></div><div class="line">PING 192.168.120.206 (192.168.120.206) 1024(1052) bytes of data.</div><div class="line">1032 bytes from 192.168.120.206: icmp_seq=1 ttl=64 time=1.99 ms</div><div class="line">1032 bytes from 192.168.120.206: icmp_seq=2 ttl=64 time=0.694 ms</div><div class="line">1032 bytes from 192.168.120.206: icmp_seq=3 ttl=64 time=0.300 ms</div><div class="line">1032 bytes from 192.168.120.206: icmp_seq=4 ttl=64 time=0.481 ms</div><div class="line">1032 bytes from 192.168.120.206: icmp_seq=5 ttl=64 time=0.415 ms</div><div class="line">1032 bytes from 192.168.120.206: icmp_seq=6 ttl=64 time=0.600 ms</div><div class="line">1032 bytes from 192.168.120.206: icmp_seq=7 ttl=64 time=0.411 ms</div><div class="line">1032 bytes from 192.168.120.206: icmp_seq=8 ttl=64 time=0.281 ms</div><div class="line">1032 bytes from 192.168.120.206: icmp_seq=9 ttl=64 time=0.318 ms</div><div class="line">1032 bytes from 192.168.120.206: icmp_seq=10 ttl=64 time=0.362 ms</div><div class="line">1032 bytes from 192.168.120.206: icmp_seq=11 ttl=64 time=0.408 ms</div><div class="line">1032 bytes from 192.168.120.206: icmp_seq=12 ttl=64 time=0.445 ms</div><div class="line">1032 bytes from 192.168.120.206: icmp_seq=13 ttl=64 time=0.397 ms</div><div class="line">1032 bytes from 192.168.120.206: icmp_seq=14 ttl=64 time=0.406 ms</div><div class="line">1032 bytes from 192.168.120.206: icmp_seq=15 ttl=64 time=0.458 ms</div><div class="line"></div><div class="line">--- 192.168.120.206 ping statistics ---</div><div class="line">15 packets transmitted, 15 received, 0% packet loss, time 41999ms</div><div class="line">rtt min/avg/max/mdev = 0.281/0.531/1.993/0.404 ms</div><div class="line">[root@localhost ~]<span class="comment">#</span></div></pre></td></tr></table></figure>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;<strong>说明</strong></p>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;-i 3 发送周期为 3秒 -s 设置发送包的大小为1024 -t 设置TTL值为 255</p>

      
    </div>

    <div>
      
        

      
    </div>

    <div>
      
        

      
    </div>

    <div>
      
        

      
    </div>

    <footer class="post-footer">
      
        <div class="post-tags">
          
            <a href="/tags/Linux命令/" rel="tag"># Linux命令</a>
          
        </div>
      

      
      
      

      
        <div class="post-nav">
          <div class="post-nav-next post-nav-item">
            
              <a href="/2017/09/03/2. Linux 命令/51. Linux 命令- at/" rel="next" title="Linux 命令- at">
                <i class="fa fa-chevron-left"></i> Linux 命令- at
              </a>
            
          </div>

          <span class="post-nav-divider"></span>

          <div class="post-nav-prev post-nav-item">
            
              <a href="/2017/09/03/2. Linux 命令/84. Linux 命令- curl/" rel="prev" title="Linux 命令- curl">
                Linux 命令- curl <i class="fa fa-chevron-right"></i>
              </a>
            
          </div>
        </div>
      

      
      
    </footer>
  </article>



    <div class="post-spread">
      
    </div>
  </div>


          </div>
          


          
  <div class="comments" id="comments">
    
  </div>


        </div>
        
          
  
  <div class="sidebar-toggle">
    <div class="sidebar-toggle-line-wrap">
      <span class="sidebar-toggle-line sidebar-toggle-line-first"></span>
      <span class="sidebar-toggle-line sidebar-toggle-line-middle"></span>
      <span class="sidebar-toggle-line sidebar-toggle-line-last"></span>
    </div>
  </div>

  <aside id="sidebar" class="sidebar">
    <div class="sidebar-inner">

      

      
        <ul class="sidebar-nav motion-element">
          <li class="sidebar-nav-toc sidebar-nav-active" data-target="post-toc-wrap" >
            文章目录
          </li>
          <li class="sidebar-nav-overview" data-target="site-overview">
            站点概览
          </li>
        </ul>
      

      <section class="site-overview sidebar-panel">
        <div class="site-author motion-element" itemprop="author" itemscope itemtype="http://schema.org/Person">
          <img class="site-author-image" itemprop="image"
               src="/images/0.png"
               alt="失落的乐章" />
          <p class="site-author-name" itemprop="name">失落的乐章</p>
           
              <p class="site-description motion-element" itemprop="description">失落的乐章的Blog</p>
          
        </div>
        <nav class="site-state motion-element">

          
            <div class="site-state-item site-state-posts">
              <a href="/">
                <span class="site-state-item-count">627</span>
                <span class="site-state-item-name">日志</span>
              </a>
            </div>
          

          

          
            
            
            <div class="site-state-item site-state-tags">
              <a href="/tags/index.html">
                <span class="site-state-item-count">38</span>
                <span class="site-state-item-name">标签</span>
              </a>
            </div>
          

        </nav>

        

        <div class="links-of-author motion-element">
          
            
              <span class="links-of-author-item">
                <a href="https://github.com/hcldirgit" target="_blank" title="GitHub">
                  
                    <i class="fa fa-fw fa-github"></i>
                  
                  GitHub
                </a>
              </span>
            
          
        </div>

        
        

        
        

        


      </section>

      
      <!--noindex-->
        <section class="post-toc-wrap motion-element sidebar-panel sidebar-panel-active">
          <div class="post-toc">

            
              
            

            
              <div class="post-toc-content"><ol class="nav"><li class="nav-item nav-level-2"><a class="nav-link" href="#1-命令格式"><span class="nav-number">1.</span> <span class="nav-text">1.命令格式</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#2-命令功能"><span class="nav-number">2.</span> <span class="nav-text">2.命令功能</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#3-命令参数"><span class="nav-number">3.</span> <span class="nav-text">3.命令参数</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#4-使用实例"><span class="nav-number">4.</span> <span class="nav-text">4.使用实例</span></a><ol class="nav-child"><li class="nav-item nav-level-3"><a class="nav-link" href="#实例1：ping的通的情况"><span class="nav-number">4.1.</span> <span class="nav-text">实例1：ping的通的情况</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#实例2：ping不通的情况"><span class="nav-number">4.2.</span> <span class="nav-text">实例2：ping不通的情况</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#实例3：ping网关"><span class="nav-number">4.3.</span> <span class="nav-text">实例3：ping网关</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#实例4：ping指定次数"><span class="nav-number">4.4.</span> <span class="nav-text">实例4：ping指定次数</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#实例5：时间间隔和次数限制的ping"><span class="nav-number">4.5.</span> <span class="nav-text">实例5：时间间隔和次数限制的ping</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#实例6：通过域名ping公网上的站点"><span class="nav-number">4.6.</span> <span class="nav-text">实例6：通过域名ping公网上的站点</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#实例7：多参数使用"><span class="nav-number">4.7.</span> <span class="nav-text">实例7：多参数使用</span></a></li></ol></li></ol></div>
            

          </div>
        </section>
      <!--/noindex-->
      

      

    </div>
  </aside>


        
      </div>
    </main>

    <footer id="footer" class="footer">
      <div class="footer-inner">
        <div class="copyright" >
  
  &copy; 
  <span itemprop="copyrightYear">2017</span>
  <span class="with-love">
    <i class="fa fa-heart"></i>
  </span>
  <span class="author" itemprop="copyrightHolder">失落的乐章</span>
</div>


<div class="powered-by">
  由 <a class="theme-link" href="https://hexo.io">Hexo</a> 强力驱动
</div>

<div class="theme-info">
  主题 -
  <a class="theme-link" href="https://github.com/iissnan/hexo-theme-next">
    NexT.Muse
  </a>
</div>


        

        
      </div>
    </footer>

    
      <div class="back-to-top">
        <i class="fa fa-arrow-up"></i>
        
      </div>
    

  </div>

  

<script type="text/javascript">
  if (Object.prototype.toString.call(window.Promise) !== '[object Function]') {
    window.Promise = null;
  }
</script>









  












  
  <script type="text/javascript" src="/lib/jquery/index.js?v=2.1.3"></script>

  
  <script type="text/javascript" src="/lib/fastclick/lib/fastclick.min.js?v=1.0.6"></script>

  
  <script type="text/javascript" src="/lib/jquery_lazyload/jquery.lazyload.js?v=1.9.7"></script>

  
  <script type="text/javascript" src="/lib/velocity/velocity.min.js?v=1.2.1"></script>

  
  <script type="text/javascript" src="/lib/velocity/velocity.ui.min.js?v=1.2.1"></script>

  
  <script type="text/javascript" src="/lib/fancybox/source/jquery.fancybox.pack.js?v=2.1.5"></script>


  


  <script type="text/javascript" src="/js/src/utils.js?v=5.1.1"></script>

  <script type="text/javascript" src="/js/src/motion.js?v=5.1.1"></script>



  
  

  
  <script type="text/javascript" src="/js/src/scrollspy.js?v=5.1.1"></script>
<script type="text/javascript" src="/js/src/post-details.js?v=5.1.1"></script>



  


  <script type="text/javascript" src="/js/src/bootstrap.js?v=5.1.1"></script>



  


  




	





  





  





  






  





  

  

  

  

  

  

</body>
</html>
